package com.itheima.d4_algorithm;

import java.util.Arrays;

/**
 *  目标：掌握选择排序。
 */
public class Test2 {
    public static void main(String[] args) {
        int[] arr={1,5,3,9,2,8,6,4,7};
        selectSort(arr);
    }
    public static void selectSort(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = i+1; j < arr.length-1; j++) {
                if(arr[i]>arr[j]){
                    int temp=arr[i];
                    arr[i]=arr[j];
                    arr[j]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
